<template>
	<view class="content">
		<view class="row">
			<view class="place" :style="{height:topHeight+'px'}">

			</view>
			<view class="logo">
				<image src="/static/logo3.png" mode="widthFix"></image>
			</view>
			<view class="swiperbox">
				<swiper :indicator-dots="true" :autoplay="true" :interval="7000" :duration="1000">
					<swiper-item>
						<view class="swiper-item" v-for="(item,index) in banner" :key="index">
							<image :src="item.file_path" mode=""></image>
						</view>
					</swiper-item>
				</swiper>
			</view>
			<!-- <view class="buy">
				<image src="/static/sm.png" mode="widthFix"></image>
			</view> -->
			<view class="btn">
				<!-- 	<button type="button" class="now" @click="toPage('/pages/about/index')">
					<text>购票须知</text>
					<view class="tips">点击查看 </view>
					<view class="iconbox">
						<uni-icons type="info" size="25" color="#fff"></uni-icons>
					</view>
				</button>
				<view class="btn-right">
					<button type="button" class="btn-type" @click="toPage('/pages/about/watch')">
						<text>参观须知</text>
						<view class="tips">点击查看 <uni-icons type="settings-filled" size="20" color="#fff"></uni-icons>
						</view>
					</button>
					<button type="button" class="btn-type" @click="toPage('/pages/about/serve')">
						<text>讲解服务</text>
						<view class="tips">点击查看 <uni-icons type="medal" size="20" color="#fff"></uni-icons> </view>
					</button>
				</view> -->
				<view class="btnitem" v-for="(item,index) in nav" :key="index"
					@click="toPage(`/pages/about/index?type=${item.key}`)">
					<image :src="item.img" mode=""></image>
					<text>{{item.title}}</text>
				</view>
			</view>
			<view class="list">
				<view class="title">
					场地信息
				</view>
				<view class="item" @click="toPage(`/pages/venue/index?id=${item.id}`)" v-for="(item,index) in list"
					:key="index">
					<view class="imgbox">
						<image :src="item.cover_path" mode=""></image>
					</view>
					<view class="info">
						<view class="name">
							{{item.name}}
						</view>
						<view class="des">
							{{item.sketch}}
						</view>
						<view class="price">
							<text class="order">立即预约</text>
							<text class="people">可预约</text>
						</view>
					</view>
				</view>
				<view class="no-list" v-if="list.length == 0">
					- 暂无数据 -
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		lst,
		index
	} from "@/api/api.js"
	export default {
		data() {
			return {
				topHeight: 0,
				page: 1,
				last_page: 1,
				list: [],
				banner: [],
				nav: [],
			}
		},
		onLoad() {
			var that = this
			uni.getSystemInfo({
				success(res) {
					that.topHeight = res.statusBarHeight
				}
			})
			this.getLst()
			this.index()
		},
		onReachBottom() {
			if (this.page < this.last_page) {
				this.page++
				this.getLst()
			}
		},
		methods: {
			index() {
				index().then(res => {
					this.banner = res.data.banner
					this.nav = res.data.nav
				})
			},
			getLst() {
				lst({
					page: this.page
				}).then(res => {
					if (res.status == 1) {
						this.list = res.data.data
						this.last_page = res.data.last_page
					} else {
						uni.$showMsg(res.msg)
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background: #f2f2f2;
	}

	.place {
		background: #8E060A;
	}

	.logo {
		background: #8E060A;
		padding: 10px;

		image {
			width: 40%;
		}
	}

	swiper {
		height: 50vw;
		max-height: 310px;

		.swiper-item {
			width: 100%;
			height: 100%;

			image {
				width: 100%;
				height: 100%;
			}
		}
	}

	.buy {
		width: 96%;
		margin: 15px auto;

		image {
			width: 100%;
		}
	}

	.btn {
		width: 100%;
		margin: 15px auto;
		margin-top: 0;
		display: flex;
		align-items: center;
		background: #fff;
		padding: 10px 0;

		.btnitem {
			flex: 1;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			text {
				margin-top: 10px;
				font-size: 14px;
			}

			image {
				width: 40px;
				height: 40px;
			}
		}

		.now {
			background: #8E060A;
			color: #fff;
			font-size: 17px;
			font-weight: bold;
			letter-spacing: 1px;
			width: 50%;
			height: 140px;
			display: flex;
			flex-direction: column;
			align-items: flex-start;
			justify-content: center;

			.iconbox {
				text-align: right;
				width: 100%;
				line-height: 10px;
			}

		}

		.tips {
			font-size: 12px;
			font-weight: normal;
			margin-top: 20px;
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: space-between;
		}

		.btn-right {
			width: 50%;
			padding-left: 2%;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;
			flex-direction: column;
			height: 140px;

			button {
				background: #8E060A;
				color: #fff;
				font-size: 16px;
				font-weight: bold;
				letter-spacing: 1px;
				width: 100%;
				height: 65px;
				display: flex;
				flex-direction: column;
				align-items: flex-start;
				justify-content: center;
				line-height: 5px;
			}
		}
	}

	.list {
		padding: 0 10px 10px;

		.title {
			text-align: center;
			font-weight: bold;
			font-size: 17px;
			margin-bottom: 10px;
		}

		.item {
			display: flex;
			background: #fff;
			border-radius: 8px;
			box-sizing: border-box;
			padding-right: 10px;
			margin-top: 15px;

			.imgbox {
				width: 40%;
				height: 120px;

				image {
					width: 100%;
					height: 100%;
					border-radius: 5px;
				}
			}

			.info {
				flex: 1;
				padding-left: 10px;

				.name {
					font-weight: bold;
					font-size: 15px;
					margin-top: 10px;
				}

				.des {
					font-size: 12px;
					color: #999;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
					overflow: hidden;
					margin-top: 8px;
					height: 32px;
					line-height: 16px;
				}

				.price {
					margin-top: 17px;
					font-size: 12px;
					color: #8E060A;
					display: flex;
					justify-content: space-between;
					align-items: center;

					.order {
						border-radius: 20px;
						font-weight: normal;
						padding: 3px 10px;
						border: 1px solid #8E060A;
					}

					.no {
						color: #999;
					}
				}
			}
		}
	}
</style>